package com.xxx.seckill.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @Author: xxx
 * @Date: 2023/1/9 20:09
 * @Description: 消费者消费消息
 */
@Service
@Slf4j
public class MQReceiver {


    @RabbitListener(queues = "queue_header02")
    public void receiverHeaders02(Message message){
        log.info("QUEUE02接收Message对象"+message);
        log.info("QUEUE02接收消息："+new String(message.getBody()));
    }

    @RabbitListener(queues = "queue_header01")
    public void receiverHeaders01(Message message){
        log.info("QUEUE01接收Message对象"+message);
        log.info("QUEUE01接收消息："+new String(message.getBody()));
    }
    

    @RabbitListener(queues = "queue_topic02")
    public void receiverTopic02(Object msg){
        log.info("(被连个queue接收)："+msg);
    }

    @RabbitListener(queues = "queue_topic01")
    public void receiverTopic01(Object msg){
        log.info("(QUEUE01接收)："+msg);
    }
    
    

    @RabbitListener(queues = "queue_direct02")
    public void receiverROUTINGKEY02(Object msg){
        log.info("queue.green接受消息："+msg);
    }

    
    
    @RabbitListener(queues = "queue_direct01")
    public void receiverROUTINGKEY01(Object msg){
        log.info("queue.red接受消息："+msg);
    }
    
    

    @RabbitListener(queues = "queue_fanout02")
    public void receiverExchange02(Object msg){
        log.info("QUEUE02接受消息："+msg);
    }
    
    @RabbitListener(queues = "queue")
    public void receiver(Object msg){
        log.info("接受消息："+msg);
    }

    
}
